﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace EPS.Contracts
{
    public partial class UserInfo : IDataErrorInfo
    {
        #region IDataErrorInfo Members

        public string Error
        {
            get { return this[null]; }
        }

        public string this[string propertyName]
        {
            get
            {
                string result = string.Empty;
                propertyName = propertyName ?? string.Empty;
                if (propertyName == string.Empty || propertyName == "LoginName")
                {
                    if (string.IsNullOrEmpty(this.LoginName))
                    {
                        result += "用户名不能为空." + Environment.NewLine;
                    }
                }

                if (propertyName == string.Empty || propertyName == "Password")
                {
                    if (string.IsNullOrEmpty(this.Password))
                    {
                        result += "密码不能为空."
                            + Environment.NewLine;
                    }
                }

                return result.TrimEnd();
            }
        }

        #endregion
    }
}
